package sql;

import parse.IntegerItem;
import parse.VarcharItem;
import Const.Constant;
import ExecuteEngine.Element;
import ExecuteEngine.Tuple;
import RecordManagement.ScanType;

public class IndexItem {
	public String tableName;
	public String attrName;

	public IndexItem(String tn, String an) {
		tableName = tn;
		attrName = an;
	}
	
	public IndexItem(byte[] stream){	
		byte data[] = new byte[Constant.MAXNAME];
		System.arraycopy(stream, 0, data, 0, Constant.MAXNAME);
		this.tableName = Tuple.Trim(new String(data));
		
		data = new byte[Constant.MAXNAME];
		System.arraycopy(stream, Constant.MAXNAME, data, 0, Constant.MAXNAME);
		this.attrName = Tuple.Trim(new String(data));
	}
	
	public byte[] getBytes(){
		int count = Constant.MAXNAME*2;
		byte stream_byte[] = new byte[count];
		
		StringBuffer temp = new StringBuffer(tableName);
		temp.setLength(Constant.MAXNAME);
		System.arraycopy(temp.toString().getBytes(), 0, stream_byte, 0, Constant.MAXNAME);
			
		temp = new StringBuffer(attrName);
		temp.setLength(Constant.MAXNAME);
		System.arraycopy(temp.toString().getBytes(), 0, stream_byte, Constant.MAXNAME, Constant.MAXNAME);
		
		return stream_byte;
	}
}
